package com.ruoyi.project.jiaqin.companyenvironment.service.impl;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.jiaqin.companyenvironment.domain.CompanyEnvironment;
import com.ruoyi.project.jiaqin.companyenvironment.mapper.CompanyEnvironmentMapper;
import com.ruoyi.project.jiaqin.companyenvironment.service.ICompanyEnvironmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * 企业环境Service业务层处理
 *
 * @author admin
 * @date 2021-01-08
 */
@Service
public class CompanyEnvironmentServiceImpl implements ICompanyEnvironmentService
{
    @Autowired
    private CompanyEnvironmentMapper companyEnvironmentMapper;

    /**
     * 查询企业环境
     *
     * @param id 企业环境ID
     * @return 企业环境
     */
    @Override
    public CompanyEnvironment selectCompanyEnvironmentById(String id)
    {
        return companyEnvironmentMapper.selectCompanyEnvironmentById(id);
    }

    /**
     * 查询企业环境列表
     *
     * @param companyEnvironment 企业环境
     * @return 企业环境
     */
    @Override
    public List<CompanyEnvironment> selectCompanyEnvironmentList(CompanyEnvironment companyEnvironment)
    {
        return companyEnvironmentMapper.selectCompanyEnvironmentList(companyEnvironment);
    }

    /**
     * 新增企业环境
     *
     * @param companyEnvironment 企业环境
     * @return 结果
     */
    @Override
    public int insertCompanyEnvironment(CompanyEnvironment companyEnvironment)
    {
        companyEnvironment.setId(UUID.randomUUID().toString().replace("-",""));
        return companyEnvironmentMapper.insertCompanyEnvironment(companyEnvironment);
    }

    /**
     * 修改企业环境
     *
     * @param companyEnvironment 企业环境
     * @return 结果
     */
    @Override
    public int updateCompanyEnvironment(CompanyEnvironment companyEnvironment)
    {
        return companyEnvironmentMapper.updateCompanyEnvironment(companyEnvironment);
    }

    /**
     * 删除企业环境对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteCompanyEnvironmentByIds(String ids)
    {
        return companyEnvironmentMapper.deleteCompanyEnvironmentByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除企业环境信息
     *
     * @param id 企业环境ID
     * @return 结果
     */
    @Override
    public int deleteCompanyEnvironmentById(String id)
    {
        return companyEnvironmentMapper.deleteCompanyEnvironmentById(id);
    }

    @Override
    public int deleteCompanyEnvironmentByCompanyId(String companyId) {
        return companyEnvironmentMapper.deleteCompanyEnvironmentByCompanyId(companyId);
    }
}
